package com.ruoyi.wms.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wms.domain.WmsInventoryCount;
import com.ruoyi.wms.service.IWmsInventoryCountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 盘点单Controller
 * 
 * @author ruoyi
 * @date 2024-10-08
 */
@RestController
@RequestMapping("/wms/count")
public class WmsInventoryCountController extends BaseController
{
    @Autowired
    private IWmsInventoryCountService wmsInventoryCountService;

    /**
     * 查询盘点单列表
     */
    @PreAuthorize("@ss.hasPermi('wms:count:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsInventoryCount wmsInventoryCount)
    {
        startPage();
        List<WmsInventoryCount> list = wmsInventoryCountService.selectWmsInventoryCountList(wmsInventoryCount);
        return getDataTable(list);
    }

    /**
     * 导出盘点单列表
     */
    @PreAuthorize("@ss.hasPermi('wms:count:export')")
    @Log(title = "盘点单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WmsInventoryCount wmsInventoryCount)
    {
        List<WmsInventoryCount> list = wmsInventoryCountService.selectWmsInventoryCountList(wmsInventoryCount);
        ExcelUtil<WmsInventoryCount> util = new ExcelUtil<WmsInventoryCount>(WmsInventoryCount.class);
        return util.exportExcel(list, "盘点单数据");
    }

    /**
     * 获取盘点单详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:count:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wmsInventoryCountService.selectWmsInventoryCountById(id));
    }

    /**
     * 新增盘点单
     */
    @PreAuthorize("@ss.hasPermi('wms:count:add')")
    @Log(title = "盘点单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsInventoryCount wmsInventoryCount)
    {
        return toAjax(wmsInventoryCountService.insertWmsInventoryCount(wmsInventoryCount));
    }

    /**
     * 修改盘点单
     */
    @PreAuthorize("@ss.hasPermi('wms:count:edit')")
    @Log(title = "盘点单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsInventoryCount wmsInventoryCount)
    {
        return toAjax(wmsInventoryCountService.updateWmsInventoryCount(wmsInventoryCount));
    }

    /**
     * 删除盘点单
     */
    @PreAuthorize("@ss.hasPermi('wms:count:remove')")
    @Log(title = "盘点单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsInventoryCountService.deleteWmsInventoryCountByIds(ids));
    }
}
